package com.task.web.controller.core;

import javax.annotation.Resource;

import com.task.common.annotation.Log;
import com.task.common.core.domain.AjaxResult;
import com.task.common.core.page.TableDataInfo;
import com.task.common.enums.BusinessType;
import com.task.core.dto.request.ProxyPlatformRequestDTO;
import com.task.core.dto.request.QuestionRequestDTO;
import com.task.core.service.CheckService;
import com.task.core.vo.resp.QuestionShowRespVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import com.task.common.core.controller.BaseController;
import com.task.core.service.QuestionInfoService;

import java.util.Collections;
import java.util.List;

/**
 * @author 迪迦.
 * @date 2025/2/11 10:20
 */
@RestController
@RequestMapping("/questionInfo")
public class QuestionInfoController extends BaseController {

  @Resource
  private QuestionInfoService questionInfoService;

  @Resource
  private CheckService checkService;


  @PreAuthorize("@ss.hasPermi('questionCenter:list')")
  @GetMapping("/getQuestionByPage")
  public TableDataInfo getQuestionByPage(QuestionRequestDTO request) {
    return getDataTable( questionInfoService.getQuestionByPage(request));
  }

  @Log(title = "问题管理", businessType = BusinessType.DELETE)
  @DeleteMapping("/deleteQuestion/{questionCode}")
  public AjaxResult deleteQuestion(@PathVariable String questionCode) {
    checkService.check("t_question_info", questionCode);
    questionInfoService.deleteQuestion(questionCode);
    return success();
  }

  @GetMapping("/fixQuestion/{questionCode}")
  public AjaxResult chackFixQuestion(@PathVariable String questionCode) {
    checkService.check("t_question_info", questionCode);
    questionInfoService.chackFixQuestion(questionCode);
    return success();
  }


}
